package edu.washington.ling.syntric.io;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;

public class TreeFileWriterFlat extends TreeFileWriter{
	
	private PrintStream pStream;

	public TreeFileWriterFlat(String path) throws IOException {
		super(path);
		try {
			pStream = new PrintStream(new FileOutputStream(new File(path)), true, "UTF8");
		} 
		catch(UnsupportedEncodingException e) {
			pStream = new PrintStream(new FileOutputStream(new File(path)), true);
		}
	}
	

	@Override
	public void close() {
		pStream.close();
	}

	@Override
	public void writeTreeRep(TreeRepresentation tr, String id) {
		for(String line: tr.getTreeLines()){
			pStream.println(line);
		}
		pStream.println();
	}

}
